Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: add timeout of 300 (5 minutes) to any test running #1440

Merged
merged 1 commit into from
May 3, 2024

Conversation

yarikoptic
Copy link
Member

@yarikoptic yarikoptic commented May 3, 2024

We recently started to encounter stalling test runs which lead to hours of stalled operation. Hopefully this would lead to failed test instead of a stall

TODOs:

  • test if in effect by making timeout too small (e.g. 2 seconds). Will do now

We recently started to encounter stalling test runs which lead to hours of
stalled operation.  Hopefully this would lead to failed test instead of a stall
@yarikoptic yarikoptic added the tests Add or improve existing tests label May 3, 2024
@yarikoptic
Copy link
Member Author

cool -- we do tests failing with

FAILED dandi/cli/tests/test_cmd_ls.py::test_ls_bids_file - Failed: Timeout >3.0s
FAILED dandi/cli/tests/test_cmd_validate.py::test_validate_severity - Failed: Timeout >3.0s
FAILED dandi/tests/test_download.py::test_download_000027[https://dandiarchive.org/dandiset/000027/0.210831.2033] - Failed: Timeout >3.0s
FAILED dandi/tests/test_download.py::test_download_000027[https://dandiarchive.org/dandiset/000027/draft] - Failed: Timeout >3.0s
FAILED dandi/tests/test_metadata.py::test_bids_nwb_metadata_integration - Failed: Timeout >3.0s

Let's hope that it would also ensure to terminate them whenever they run out of time. I think at some point in the past it was not the case with this machinery, but on my trivial test today it seems to be the case:

❯ time python -m pytest -s -v --timeout 10 /tmp/test_sample.py
=============================================================================== test session starts ================================================================================
platform linux -- Python 3.11.9, pytest-7.4.4, pluggy-1.5.0 -- /usr/bin/python
cachedir: .pytest_cache
rootdir: /tmp
plugins: anyio-4.3.0, timeout-2.3.1
timeout: 10.0s
timeout method: signal
timeout func_only: False
collected 1 item                                                                                                                                                                   

../../../../../tmp/test_sample.py::test_foo .
FAILED

===================================================================================== FAILURES =====================================================================================
_____________________________________________________________________________________ test_foo _____________________________________________________________________________________

    @pytest.mark.timeout(1)
    def test_foo():
        for i in range(3):
            print('.')
>           sleep(1)
E           Failed: Timeout >1.0s

/tmp/test_sample.py:8: Failed
============================================================================= short test summary info ==============================================================================
FAILED ../../../../../tmp/test_sample.py::test_foo - Failed: Timeout >1.0s
================================================================================ 1 failed in 1.11s =================================================================================
python -m pytest -s -v --timeout 10 /tmp/test_sample.py  0.51s user 0.07s system 36% cpu 1.580 total

where we see that overall run is less than "planned" 3 seconds of the loop... ok -- removing TEMP commit now

Copy link

codecov bot commented May 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.69%. Comparing base (260b4d7) to head (659c237).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1440      +/-   ##
==========================================
+ Coverage   88.61%   88.69%   +0.08%     
==========================================
  Files          77       77              
  Lines       10563    10563              
==========================================
+ Hits         9360     9369       +9     
+ Misses       1203     1194       -9     
Flag Coverage Δ
unittests 88.69% <ø> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yarikoptic
Copy link
Member Author

all good besides the

@yarikoptic yarikoptic merged commit 722f1b6 into master May 3, 2024
34 of 54 checks passed
@yarikoptic yarikoptic deleted the enh-timeout branch May 3, 2024 22:08
Copy link

🚀 PR was released in 0.62.1 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released tests Add or improve existing tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant